package com.pur.zsms.auto;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.pur.zsms.accountmanage.web.AccountControllor;
import com.pur.zsms.common.exception.GenericException;
import com.pur.zsms.common.util.PubFun;
import com.pur.zsms.ordercustommanage.dao.ISelectFoodDao;
import com.pur.zsms.storemanage.po.StoreInDetailedPo;
import com.pur.zsms.storemanage.service.IStoreService;

public class AccountValue {
	@SuppressWarnings("unused")
	private static final Logger log = LoggerFactory.getLogger(AccountValue.class);

	private Timestamp preTime = null;

	@Resource(name = "storeService")
	private IStoreService storeServiceDaoImpl;

	public IStoreService getStoreServiceDaoImpl() {
		return storeServiceDaoImpl;
	}

	public void setStoreServiceDaoImpl(IStoreService storeServiceDaoImpl) {
		this.storeServiceDaoImpl = storeServiceDaoImpl;
	}

	public void send() {
		preTime = new Timestamp(System.currentTimeMillis());
		log.info("----自动计算财务价格开始——————" + preTime);

		try {
			List list = storeServiceDaoImpl.getStoreInDetailedPoListDealValue();
			for (Object object : list) {
				Object[] item = (Object[]) object;
				List listValue = storeServiceDaoImpl.getRealValue((Integer) item[0]);
				if (listValue != null && listValue.size() > 0) {

					StoreInDetailedPo tStoreInDetailedPo =storeServiceDaoImpl.getStoreInDetailedPo((Integer) item[0]);
					tStoreInDetailedPo.setAccountDate(PubFun.getCurrentDate());
					tStoreInDetailedPo.setAccountState(1);
					tStoreInDetailedPo.setMaterValueUnit(new BigDecimal(listValue.get(0).toString()));
					storeServiceDaoImpl.addStoreInDetailedOne(tStoreInDetailedPo);
				}
			}
		} catch (GenericException e) {
			e.printStackTrace();
		}

	}

}